/**
 *  @file CmdLineParser.h
 */
#ifndef _CMDLINEPARSER_H_
#define _CMDLINEPARSER_H_

#include "../common/BaseObject.h"
#include "../text/CFString.h"
#include "../collections/LinkedHashtableT.h"

namespace cppflib
{

namespace util
{

/**
 *  To parse command line arguments
 */
class _DLLAPI CmdLineParser : public BaseObject
{
private:
    //! program name
    CFString *progName;
    //! argument option table
    collections::LinkedHashtableT<CFString, BaseObject> * pArgTable;
    //! to hold unclassified objects
    collections::ListCppObjT<CFString> *pUnclassifiedList;

private: 
    CmdLineParser(void);
    void Parse(collections::ArrayCppObjT<CFString> & argArray, 
               collections::HashtableT<CFString, CFString> & optWithArgTbl);
    void AddUnclassified(CFString *pUnc);

public:
    CmdLineParser(int argc, char * argv[], pcwstr_t optWithArg[]);    
    CmdLineParser(int argc, pwstr_t argv[], pcwstr_t optWithArg[]);
    virtual ~CmdLineParser(void);

    const CFString& GetProgramName();

    u32_t GetTotalOptionCount();
    bool ContainsOption(pcwstr_t opt);
    const CFString& GetOption(int index);

    u32_t GetOptionCount(pcwstr_t opt);    
    bool GetOption(pcwstr_t opt, int optIndex, CFString& name, CFString& val);

    u32_t GetUnclassifiedCount();
    const CFString& GetUnclassified(int index);
};

} // end of namespace util

} // end of namespace cppflib

#endif
